PROJECT(SimuHuit2)

CMAKE_MINIMUM_REQUIRED(VERSION 2.4)

if(COMMAND cmake_policy)
	cmake_policy(SET CMP0003 NEW) 
endif(COMMAND cmake_policy)

FIND_PACKAGE(wxWidgets REQUIRED )

# We need the Find package for wxWidgets to work
FIND_PACKAGE(wxWidgets COMPONENTS "${wxWidgets_MRPT_COMPONENTS_TO_SEARCH}")
# Did we find wxWidgets ? This condition will fail for as long as the internal vars do not point to the proper wxWidgets configuration
IF(wxWidgets_FOUND)
	# Check for non-found debug libs:
	IF(UNIX)
		IF(CMAKE_BUILD_TYPE MATCHES "Debug")
			IF(NOT wxWidgets_USE_DEBUG)
				MESSAGE("Warning: The debug libraries for wxWidgets couldn't be found by CMake. Please install them (libwxbase2.8-dev) or build in release.")
			ENDIF(NOT wxWidgets_USE_DEBUG)
		ENDIF(CMAKE_BUILD_TYPE MATCHES "Debug")
	ENDIF(UNIX)

	# Include wxWidgets macros
	INCLUDE(${wxWidgets_USE_FILE})
	# ${wxWidgets_LIBRARIES}  will contain the libraries that should be added through TARGET_LINK_LIBRARIES(...)
	#MESSAGE(STATUS "wxWidgets:")
	#MESSAGE(STATUS "   wxWidgets_LIBRARY_DIRS  : ${wxWidgets_LIBRARY_DIRS}")
	#MESSAGE(STATUS "   wxWidgets_CXX_FLAGS     : ${wxWidgets_CXX_FLAGS}")
	#MESSAGE(STATUS "   wxWidgets_INCLUDE_DIRS  : ${wxWidgets_INCLUDE_DIRS}")

	LINK_DIRECTORIES(${wxWidgets_LIBRARY_DIRS})

	IF(MSVC)
		ADD_DEFINITIONS(-DwxUSE_NO_MANIFEST=1)
	ENDIF(MSVC)

	IF(CMAKE_COMPILER_IS_GNUCXX)
		# Add -isystem for wx headers (seems not to be added automatically for GCC in mac osx)
		FOREACH(WXDIR ${wxWidgets_INCLUDE_DIRS})
			SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${WXDIR} -isystem ${WXDIR}")
		ENDFOREACH(WXDIR)
	ENDIF(CMAKE_COMPILER_IS_GNUCXX)

	# For use in the MRPTconfig.cmake
	SET(CMAKE_MRPT_WX_ROOT_DIR ${wxWidgets_ROOT_DIR})

	SET(CMAKE_MRPT_HAS_WXWIDGETS 1)
ENDIF(wxWidgets_FOUND)

FIND_PACKAGE( MRPT REQUIRED base slam hwdrivers gui)


ADD_EXECUTABLE(SimuHuit
	SimuHuit.cpp CFlyingRobot.cpp CFilt2.cpp Quad3DModel.cpp CLaserSensor.cpp CPilot.cpp CQuadrotor.cpp AutoPilot.cpp GluePose.cpp GlueScan.cpp
	)

TARGET_LINK_LIBRARIES(SimuHuit ${MRPT_LIBS} ${wxWidgets_LIBRARIES} )
